package com.javalong.affairs.module.main.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.javalong.affairs.R;
import com.javalong.affairs.base.activity.WebViewActivity;
import com.javalong.affairs.base.constant.BundleKey;
import com.javalong.affairs.base.fragment.BaseFragment;
import com.javalong.affairs.base.manager.IntentManager;
import com.javalong.affairs.base.utils.UrlUtils;
import com.javalong.affairs.module.main.activity.NewMainActivity;
import com.javalong.affairs.module.notifything.activity.NotificationActivity;
import com.javalong.affairs.module.renwujinzhang.activity.TrackTaskActivity;
import com.javalong.affairs.module.renwujinzhang.activity.receive.ReceiveListActivity;

/**
 * Created by javalong on 2016/5/15.
 */

public class MainFragment extends BaseFragment implements View.OnClickListener {

    private ImageView iv_task_track;
    private ImageView iv_notify;
    private ImageView iv_study;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_main, container, false);
        initUI(view);
        initData();
        return view;
    }

    private void initUI(View view) {
        iv_task_track = (ImageView) view.findViewById(R.id.iv_task_track);
        iv_notify = (ImageView) view.findViewById(R.id.iv_notify);
        iv_study = (ImageView) view.findViewById(R.id.iv_study);
    }

    private void initData() {
        iv_task_track.setOnClickListener(this);
        iv_notify.setOnClickListener(this);
        iv_study.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.iv_task_track:
                IntentManager.doActivity(getActivity(),
                        ReceiveListActivity.class);
                break;
            case R.id.iv_notify:
                IntentManager.doActivity(getActivity(),
                        NotificationActivity.class);
                break;
            case R.id.iv_study:
                Bundle bundle = new Bundle();
                bundle.putString(BundleKey.URL,
                        UrlUtils.getUrl("StudyShow", "outWeb_content"));
                IntentManager.doActivity2(getActivity(), WebViewActivity.class, bundle);
                break;
        }
    }
}
